package JUC;

//class MyThread implements Runnable{
//
//    @Override
//    public void run() {
//
//    }
//}

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyThread implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println(Thread.currentThread().getName() +
                "\tCome in ");
        Thread.sleep(3000);
        return 1024;
    }
}

public class CallableDemo {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> futureTask = new FutureTask<>(new MyThread());

        new Thread(futureTask, "AA").start();
        new Thread(futureTask, "BB").start();
        System.out.println("main");
        int res01 = 10;
        int res02 = futureTask.get();


        System.out.println(res01 + res02);
    }
}
